import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:todo_app/constants/Screen.dart';
import 'package:todo_app/controllers/definitions/RtcRoomModel.dart';
import 'package:todo_app/layout/Gaps.dart';
import 'package:todo_app/layout/Space.dart';
import 'package:todo_app/pages/person/component/UserCard.dart';
import 'package:todo_app/utils/call/CallHelper.dart';
import 'package:todo_app/utils/webrtc/section/CallIcons.dart';

class CallInSection extends HookWidget {
  const CallInSection(this.room, {Key? key}) : super(key: key);
  final RtcRoomModel room;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: const Color(0xFF1a3d4d),
      body: SizedBox(
        width: Screen.width,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            const SizedBox(height: 168,),
            UserAvatar(size: 120, url: room.caller.avatar),
            Gaps.vGap16,
            Text(room.caller.nickname ?? room.caller.mobile ?? "用户", style: TextStyle(color: Colors.white, fontSize: 22.dp) ),
            Gaps.vGap4,
            Text("邀请你视频通话", style: TextStyle(color: Colors.white, fontSize: 12.dp) ),
            const Spacer(),
            Space(
              gutter: 50.dp,
              children: [
                GestureDetector(
                  onTap: () {
                    CallUIHelper.reject(room.room_id!);
                  },
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      const CallEndIcon(),
                      Gaps.vGap12,
                      const Text("拒绝", style: TextStyle(color: Colors.white),)
                    ],
                  ),
                ),
                GestureDetector(
                  onTap: () {
                    CallUIHelper.accept(room);
                  },
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      const CallIcon(),
                      Gaps.vGap12,
                      const Text("接听", style: TextStyle(color: Colors.white),)
                    ],
                  ),
                )
              ]
            ),
            SizedBox(height: 120.dp,)
          ]
        ),
      ),
    );
  }
}